// LoginResponse.java
package com.tzkyzj.tiremanager.dto;


import com.tzkyzj.tiremanager.entity.User;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class LoginResponse {
    private boolean success;
    private String message;
    private String token;
    private UserInfo userInfo;

    // 构造方法、getter、setter
    // 加在 LoginResponse.java 内
    public void setUser(User u) {
        if (u == null) {
            this.userInfo = null;
            return;
        }
        this.userInfo = UserInfo.builder()
                .id(u.getId())
                .username(u.getUsername())
                .role(u.getRole().toString())
                .transportCompany(u.getTransportCompany())
                .vehiclePlateNumber(u.getVehiclePlateNumber())
                .build();
    }
}